<?php

namespace bc\model\source;

use bc\ar\MActiveRecord;

class LogModel extends MActiveRecord
{
	public static function tableName()
	{
		return '{{%source_statistics_log}}';
	}
	
	
	/**
	 * 
	 * @param int $id
	 * @param int $start_time
	 * @param int $end_time
	 */
	public function analysis($id, $start_time, $end_time)
	{
		$sql = 'SELECT count(1) AS total FROM ' . LogModel::getTableSchema()->name . ' WHERE statistics_id = ' .$id . ' AND create_time >= ' . $start_time . ' AND create_time <= ' . $end_time; 
		$row = $this->getDb()->createCommand($sql)->queryOne();
		return $row['total'];
	}
}

